import { Redirect } from 'umi';

export default (props: any) => {
  const token = sessionStorage.getItem('token');
  if (props.location.pathname === '/') {
    if (token) {
      return <Redirect to={'/index'}></Redirect>;
    }
  } else {
    if (!token) {
      return <Redirect to="/"></Redirect>;
    }
  }
  return <>{props.children}</>;
};
